from flask_restful import Resource

from restful.api__.session import login_required_current_user_generate, uid_required_target_user_generate
from restful.model.query import QueryOneInstance
from restful.model.tables import Like, Follow
from restful.response import ResponseSuccess


class UserAlreadyFollow(Resource):
    @login_required_current_user_generate
    @uid_required_target_user_generate
    def get(self, current_user, target_user):
        follow = QueryOneInstance(Follow, {'uid': current_user.id, 'uid1': target_user.id})

        return ResponseSuccess(data={
            'already_follow': bool(follow)
        })